package sc.test.spring.threads;

import java.util.concurrent.Callable;

import sc.common.test.TestUtil;

public class CoolCallable implements Callable<Object> {

    public CoolCallable(String name, int sleepMilli, boolean mute) {
        this.name = name;
        this.sleepMilli = sleepMilli;
        this.mute = mute;
    }

    String name;
    int sleepMilli;
    boolean mute;

    @Override
    public Object call() throws Exception {
        try {
            Thread.sleep(sleepMilli);
            if (!mute) {
                TestUtil.sp("%10s sleeped %10d(ms)", name, sleepMilli);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return sleepMilli;
    }

}
